package com.momomian.common.exception;

import com.momomian.common.enums.ResCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author momomian
 * @version 1.0
 * @date 2020/3/28
 * @description 业务异常处理类
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString
public class BusinessException extends RuntimeException implements Serializable {

    private static final long serialVersionUID = 1L;


    private String msg;

    private int code = ResCodeEnum.ERROR3000.getCode();


    public BusinessException(int code) {
        this.code = code;
        this.msg = ResCodeEnum.getDescription(code);
    }

    public BusinessException(String msg) {
        super(msg);
        this.msg = msg;
    }

    public BusinessException(String msg, Throwable e) {
        super(msg, e);
        this.msg = msg;
    }

    public BusinessException(String msg, int code) {
        super(msg);
        this.msg = msg;
        this.code = code;
    }
    public BusinessException(int code,String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BusinessException(String msg, int code, Throwable e) {
        super(msg, e);
        this.msg = msg;
        this.code = code;
    }
}
